import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/notice_list_entity.dart';

NoticeListEntity $NoticeListEntityFromJson(Map<String, dynamic> json) {
  final NoticeListEntity noticeListEntity = NoticeListEntity();
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    noticeListEntity.total = total;
  }
  final List<NoticeData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<NoticeData>(e) as NoticeData).toList();
  if (data != null) {
    noticeListEntity.data = data;
  }
  return noticeListEntity;
}

Map<String, dynamic> $NoticeListEntityToJson(NoticeListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['total'] = entity.total;
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  return data;
}

extension NoticeListEntityExtension on NoticeListEntity {
  NoticeListEntity copyWith({
    int? total,
    List<NoticeData>? data,
  }) {
    return NoticeListEntity()
      ..total = total ?? this.total
      ..data = data ?? this.data;
  }
}

NoticeData $NoticeDataFromJson(Map<String, dynamic> json) {
  final NoticeData noticeData = NoticeData();
  final int? createdAt = jsonConvert.convert<int>(json['createdAt']);
  if (createdAt != null) {
    noticeData.createdAt = createdAt;
  }
  final int? updatedAt = jsonConvert.convert<int>(json['updatedAt']);
  if (updatedAt != null) {
    noticeData.updatedAt = updatedAt;
  }
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    noticeData.id = id;
  }
  final String? uid = jsonConvert.convert<String>(json['uid']);
  if (uid != null) {
    noticeData.uid = uid;
  }
  final String? orgId = jsonConvert.convert<String>(json['orgId']);
  if (orgId != null) {
    noticeData.orgId = orgId;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    noticeData.name = name;
  }
  final String? target = jsonConvert.convert<String>(json['target']);
  if (target != null) {
    noticeData.target = target;
  }
  final int? type = jsonConvert.convert<int>(json['type']);
  if (type != null) {
    noticeData.type = type;
  }
  final int? shareType = jsonConvert.convert<int>(json['shareType']);
  if (shareType != null) {
    noticeData.shareType = shareType;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    noticeData.title = title;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    noticeData.content = content;
  }
  final String? phoneNumber = jsonConvert.convert<String>(json['phoneNumber']);
  if (phoneNumber != null) {
    noticeData.phoneNumber = phoneNumber;
  }
  final String? remark = jsonConvert.convert<String>(json['remark']);
  if (remark != null) {
    noticeData.remark = remark;
  }
  final bool? isRead = jsonConvert.convert<bool>(json['isRead']);
  if (isRead != null) {
    noticeData.isRead = isRead;
  }
  return noticeData;
}

Map<String, dynamic> $NoticeDataToJson(NoticeData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['createdAt'] = entity.createdAt;
  data['updatedAt'] = entity.updatedAt;
  data['id'] = entity.id;
  data['uid'] = entity.uid;
  data['orgId'] = entity.orgId;
  data['name'] = entity.name;
  data['target'] = entity.target;
  data['type'] = entity.type;
  data['shareType'] = entity.shareType;
  data['title'] = entity.title;
  data['content'] = entity.content;
  data['phoneNumber'] = entity.phoneNumber;
  data['remark'] = entity.remark;
  data['isRead'] = entity.isRead;
  return data;
}

extension NoticeDataExtension on NoticeData {
  NoticeData copyWith({
    int? createdAt,
    int? updatedAt,
    int? id,
    String? uid,
    String? orgId,
    String? name,
    String? target,
    int? type,
    int? shareType,
    String? title,
    String? content,
    String? phoneNumber,
    String? remark,
    bool? isRead,
  }) {
    return NoticeData()
      ..createdAt = createdAt ?? this.createdAt
      ..updatedAt = updatedAt ?? this.updatedAt
      ..id = id ?? this.id
      ..uid = uid ?? this.uid
      ..orgId = orgId ?? this.orgId
      ..name = name ?? this.name
      ..target = target ?? this.target
      ..type = type ?? this.type
      ..shareType = shareType ?? this.shareType
      ..title = title ?? this.title
      ..content = content ?? this.content
      ..phoneNumber = phoneNumber ?? this.phoneNumber
      ..remark = remark ?? this.remark
      ..isRead = isRead ?? this.isRead;
  }
}